<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-3" style="width: 100%;">
                            <div class="input-group" style="width: 100%;">
                                <input id="name" type="text" placeholder="请输入名称" class="input-sm form-control" style="width: 15%;">
                                <span class="input-group-btn"  style="float: left;">
                                        <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> </span>
	                            <s:hasPermission name="invoice:add">
	                            	 <span class="input-group-btn" style="float: left; margin-left: 25px;">
	                             		<a  class="btn btn-sm btn-success" style="margin-left: 20px;" onclick="showadd();"> 添加</a>
	                             	 </span>
	                            </s:hasPermission>
                             </div>
                        </div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    $(top.hangge());
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/invoice/listData',
            datatype: "json",
            postData: {}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            sortname: 'createDate',
            sortorder: "desc",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"发票类型",
			"税号",
			"金额",
			"合同编号",
			"公司名称",
			"开票内容",
			"候选人",
			"入职岗位",
			"入职日期",
			"保障期结束日期",
			"收款类别",
			"发票状态",
			"备注",
	         "操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"type",index:"type",width:100,
				formatter: function (value, options, row) {
					var htm="";
					if(value == 1){
						htm = "<span class='label label-primary'>普票</span>";
					}else if(value == 2){
						htm = "<span class='label label-info'>专票</span>";
					}else {
						htm = "<span class='label label-default'>暂无</span>";
					}
					return htm;
				}
			},
			{name:"taxNum",index:"taxNum",width:100},
			{name:"amount",index:"amount",width:100},
			{name:"contractNo",index:"contractNo",width:100},
			{name:"companyName",index:"companyName",width:100},
			{name:"content",index:"content",width:100},
			{name:"candidate",index:"candidate",width:100},
			{name:"inPost",index:"inPost",width:100},
			{name:"entryDate",index:"entryDate",width:100},
			{name:"endDate",index:"endDate",width:100},
			{name:"receiptType",index:"receiptType",width:100,
				formatter: function (value, options, row) {
					var htm="";
					if(value == 1){
						htm = "<span class='label label-primary'>预付款</span>";
					}else if(value == 2){
						htm = "<span class='label label-success'>首款</span>";
					}else if(value == 3){
						htm = "<span class='label label-info'>尾款</span>";
					}else {
						htm = "<span class='label label-default'>暂无</span>";
					}
					return htm;
				}	
			},
			{name:"status",index:"status",width:100,
				formatter: function (value, options, row) {
					var htm="";
					if(value == 1){
						htm = "<span class='label label-success'>已开</span>";
					}else if(value == 2){
						htm = "<span class='label label-danger'>未开</span>";
					}else {
						htm = "<span class='label label-default'>暂无</span>";
					}
					return htm;
				}		
			},
			{name:"remark",index:"remark",width:100},
	        {
                formatter: function (cellvalue, options, row) {
                    return " <s:hasPermission name="invoice:detail"><a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> " 
                         + " <s:hasPermission name="invoice:edit"><a class='btn btn-sm btn-warning' title='修改' onclick='showedit(&quot;" + row.id + "&quot;)'><i class='icon-edit'></i></a></s:hasPermission> "
                         + " <s:hasPermission name="invoice:delete"><a class='btn btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
                },
                width: 180
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
            var name = $("#name").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        
    //查看
    function showeye(id) {
        openyem("查看发票管理", "<%=contextPath%>/invoice/detailView?id=" + id, 1080, 720);
    }
    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/invoice/delete");
    };
    //修改
    function showedit(id) {
        openyem("修改发票管理", "<%=contextPath%>/invoice/editView?id=" + id, 1080, 720);
    }
    //添加
    function showadd(id) {
        openyem("添加发票管理", "<%=contextPath%>/invoice/addView", 1080, 720);
    }
</script>
</body>
</html>

